package org.dubnation.car.esdoc;

import lombok.Data;
import org.elasticsearch.common.geo.GeoPoint;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.GeoPointField;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 车辆索引库
 */
@Data
@Document(indexName = "ronghua-car", type = "car")
public class CarDoc {

    @Id
    private Long id;  //文档id字段
    @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    private String title;
    @Field(type = FieldType.Keyword)
    private String cover;
    @Field(type = FieldType.Double)
    private Double salePrice; //es不支持BigDecimal类型
    @Field(type = FieldType.Double)
    private Double costPrice;
    @Field(type = FieldType.Integer)
    private Integer isNew;
    @Field(type = FieldType.Date)
    private Date registerTime;
    @Field(type = FieldType.Double)
    private Double mileage;

    @Field(type = FieldType.Long)
    private Long shopId;
    @Field(type = FieldType.Keyword)
    private String shopName;
    @Field(type = FieldType.Keyword)
    private String shopAddress;
    @GeoPointField
    private GeoPoint shopPoint;  //代表店铺的经纬度
    @Field(type = FieldType.Date)
    private Date onSaleTime;
    @Field(type = FieldType.Integer)
    private Integer costEffective;
    @Field(type = FieldType.Integer)
    private Integer rushSale;
    @Field(type = FieldType.Integer)
    private Integer quasiNewCar;
    @Field(type = FieldType.Integer)
    private Integer transitiveCountry;

    @Field(type = FieldType.Long)
    private Long typeId;
    @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    private String typeName;

    @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart")
    private String carInfo;
    @Field(type = FieldType.Keyword)
    private String brand;
}